clear all
set more off
cd "/Users/yasenov/Dropbox (IPL)/RefugeeBan/Data"

use "WRAPS/wraps_fips.dta"

keep if year >= 2010

merge 1:1 fips year using "crime/crime.dta", keep(1 3) keepusing(property violent)
keep if _merge == 3  
drop _merge

merge 1:1 fips year using "demographics/demographics.dta", keep(1 3)
assert _merge == 3
drop _merge

gen statefip = substr(fips,1,2)

******************
******************
******************

gen lproperty_crime = log(property_crime + 1)
gen rproperty_crime = (property_crime / pop_total) * 100000

gen lviolent_crime = log(violent_crime + 1)
gen rviolent_crime = (violent_crime / pop_total) * 100000

gen lrefugees = log(refugees + 1)
gen rrefugees = (refugee / pop_total) * 100

replace pop_total = pop_total / 1e5

******************
******************
******************

label var rproperty "Property crimes rate"
label var rviole "Violent crimes rate"

label var lproperty "Log property crimes"
label var lviole "Log violent crimes"

label var rrefugees "Refugee arrivals per 100 people"
label var lrefugees "Log refugee arrivals"
label var refugees "Refugee arrivals"

label var pop_total "Population (in 100,000s)"

sum
tab year, m
			
estpost sum rproperty rviol lprop lviol refug rref lref pop_total, d 
esttab using "../results/tab_sumstats_unformatted.tex", ///
	cells((mean(fmt(%3.2f) label("Mean")) ///
	p50(fmt(%3.2f) label("Median")) ///
	sd(fmt(%3.2f) label("SD")) ///
	min(fmt(%1.0f) label("Min")) ///
	max(fmt(%5.2f) label("Max")) ///
	count(fmt(%4.0f) label("Observations")))) ///
	nonumber nomtitle label replace
